package core;


import com.android.volley.VolleyError;

/**
 * 统一错误，只有在网络出错的情况下才会去设置网络码
 */
public class DataError extends Exception {

    public static final int DEFAULT_NET_SUCCESS = -2; //默认网络部分是正常的
    public static final int VOLLEY_ERROR = -3;

    public int netCode = DEFAULT_NET_SUCCESS; //网络部分代码
    public String status; //响应错误码
    public String message; //响应错误说明

    public DataError(String status, String message) {
        super(message);
        this.status = status;
        this.message = message;
    }

    public DataError(VolleyError volleyError) {
        super(volleyError);
        if (volleyError.networkResponse == null) {
            netCode = VOLLEY_ERROR;
        } else {
            netCode = volleyError.networkResponse.statusCode;
        }
        this.status = ErrorMsgUtil.STATUS_NET_ERROR;
        this.message = ErrorMsgUtil.ERR_MSG_NET_ERROR;
    }
}
